package it.appcatalogobase;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

import it.appcatalogobase.MainActivity.PlaceholderFragment;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
 
public class CatalogoFragment extends Fragment {
	private Activity activity;

	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        View rootView = inflater.inflate(R.layout.fragment_catalogo, container, false);
        
		 return rootView;
    }
	
	@Override
    public void onActivityCreated(Bundle savedInstanceState){
    	super.onActivityCreated(savedInstanceState); 
    	activity = (Main2Activity) getActivity();
        DataAppPersistence appData = (DataAppPersistence)activity.getApplication();
//		if (savedInstanceState == null) {
//			getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
//		}
		Button b = (Button) activity.findViewById(R.id.button1);
		 if(appData.isSync()){
			 b.setEnabled(true);
		 }else{
			 ConnectivityManager conMgr = (ConnectivityManager) activity.getSystemService(activity.CONNECTIVITY_SERVICE);
			 NetworkInfo intC = conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
			 
			 if(intC.isConnected()){
				 MyAsyncTask task = new MyAsyncTask("www.tempogara.it/arcobaleno/temp/catalogo.php?data=categorie", activity);
				 task.execute();			 
				 b.setEnabled(false);
				 appData.setSync(true);
				 
				 
			 }
		 }
    }
		
		 
//		 TextView txt = (TextView) findViewById(R.id.textView1);
//		 AssetManager assetManager = getAssets();
//	        InputStream inputStream=null;
//	        Properties properties=null;
//			try {
//				inputStream = assetManager.open("config.properties");
//				properties = new Properties();
//				properties.load(inputStream);
//			} catch (IOException e5) {
//				// TODO Auto-generated catch block
//				e5.printStackTrace();
//			}
//			
//		 txt.setText(Html.fromHtml("<p style='text-align: center;'><span style='font-size: 12pt; color: #ff0000;'><strong>Frog Revolution </strong></span></p>\r\n<p><span style='font-size: 10pt;'>Un mix perfetto di design e praticit&agrave;, che stimola il piacere dello sguardo.</span></p>\r\n<p><span style='font-size: 10pt;'>La Frog &egrave; una macchina da caff&egrave; espresso a cialde destinata sia al mercato domestico che quello aziendale. </span></p>\r\n<p><span style='font-size: 10pt;'>Il suo design innovativo, la sua semplicit&agrave; e la qualit&agrave; delle sue componenti, la rendono un bene strumentale affidabile a cui puntare in tutta tranquillit&agrave;. </span></p>\r\n<p><span style='font-size: 10pt;'><strong>DIMENSIONI:</strong></span></p>\r\n<ul>\r\n<li><span style='font-size: 10pt;'>Larghezza: 22 cm </span></li>\r\n<li><span style='font-size: 10pt;'>Altezza: 40 cm</span></li>\r\n<li><span style='font-size: 10pt;'>Profondit&agrave;: 32 cm</span></li>\r\n<li><span style='font-size: 10pt;'>Peso: 6.5 Kg</span></li>\r\n</ul>\r\n<p><span style='font-size: 10pt;'><strong>CARATTERISTICHE TECNICHE</strong></span></p>\r\n<ul>\r\n<li><span style='font-size: 10pt;'>Potenza normale 650 W </span></li>\r\n<li><span style='font-size: 10pt;'>Voltaggio 230 V</span></li>\r\n<li><span style='font-size: 10pt;'>Sistema di decalcificazione rapido </span></li>\r\n<li><span style='font-size: 10pt;'>Alloggio bottiglia d'acqua </span></li>\r\n</ul>\r\n<p><span style='font-size: 10pt;'><strong>ACCESSORI</strong></span></p>\r\n<ul>\r\n<li><span style='font-size: 10pt;'>Vano porta cialde e bicchieri</span></li>\r\n</ul>"),TextView.BufferType.SPANNABLE);
		

        
    }
